//package com.gitlab.lucky.admin.service;
//
//import cn.hutool.http.HttpUtil;
//import com.alibaba.fastjson.JSONObject;
//import com.github.pagehelper.PageInfo;
//import com.gitlab.lucky.admin.web.dto.PlatformRequest;
//import com.gitlab.lucky.common.dao.mapper.WeixinGzhUserMapper;
//import com.gitlab.lucky.common.dao.model.WeixinGzhUser;
//import com.gitlab.lucky.common.enums.Constant;
//import com.gitlab.lucky.common.service.ServiceImpl;
//import com.gitlab.lucky.common.weixin.WeixinUtil;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//import tk.mybatis.mapper.entity.Example;
//
//@Service
//public class UserService extends ServiceImpl<WeixinGzhUserMapper, WeixinGzhUser>{
//    @Autowired
//    private WeixinUtil weixinUtil;
//    public PageInfo<WeixinGzhUser> list(PlatformRequest p) {
//        Example example = new Example(WeixinGzhUser.class);
//        example.createCriteria().andEqualTo("platform", p.getPlatform());
//        example.orderBy("subscribeTime").desc();
//        PageInfo<WeixinGzhUser> data = this.selectPage(p.getPageNum(), p.getPageSize(),example);
//        return data;
//    }
//
//    public void update(WeixinGzhUser user){
//        String accessToken = weixinUtil.getAccessToken(user.getPlatform());
//        //调用微信获取微信用户信息
//        String url = String.format(Constant.GET_WX_USER_INFO_URL, accessToken, user.getOpenid());
//        //请求
//        String result = HttpUtil.get(url);
//        //结果集转对象
//        WeixinGzhUser weixinGzhUser = JSONObject.parseObject(result, WeixinGzhUser.class);
//        weixinGzhUser.setId(user.getId());
//        this.updateByPrimaryKeySelective(weixinGzhUser);
//    }
//    public void delete(Long id){
//        this.deleteByPrimaryKey(id);
//    }
//
//}
